package com.example.es_demo.pojo;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实体类与文档形成映射关系
 */
@Document(indexName = "zut_mobile",replicas = 1,shards = 1,createIndex = true)
public class Student implements Serializable {

    @Id
    @Field(type = FieldType.Long)
    private Long id;
    //Keyword 不可分词
    @Field(type = FieldType.Keyword)
    private String name;
    @Field(type = FieldType.Keyword)
    private String number;
    //text :可分词
    @Field(type = FieldType.Text,analyzer = "ik_smart")
    private String school;
    private int age;

    @Field(type = FieldType.Date,pattern = "yyyy-MM-dd HH:mm:ss",format = DateFormat.custom)
    private LocalDateTime create_time;

    public Student() {

    }

    public Student(Long id, String name, String number, String school, int age, LocalDateTime create_time) {
        this.id = id;
        this.name = name;
        this.number = number;
        this.school = school;
        this.age = age;
        this.create_time = create_time;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public LocalDateTime getCreate_time() {
        return create_time;
    }

    public void setCreate_time(LocalDateTime create_time) {
        this.create_time = create_time;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", number='" + number + '\'' +
                ", major='" + school + '\'' +
                ", age=" + age +
                ", create_time=" + create_time +
                '}';
    }
}
